import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '客户名称',
    align:"center",
    sorter: true,
    dataIndex: 'name'
   },
   {
    title: '下拉状态',
    align:"center",
    dataIndex: 'status_dictText'
   },
   {
    title: '下拉单选职务',
    align:"center",
    dataIndex: 'positionId_dictText'
   },
   {
    title: '年龄',
    align:"center",
    dataIndex: 'yearsOld'
   },
   {
    title: '生日',
    align:"center",
    dataIndex: 'birtd',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
   },
   {
    title: '单选状态',
    align:"center",
    dataIndex: 'otherStatus_dictText'
   },
   {
    title: '部门',
    align:"center",
    dataIndex: 'depart_dictText'
   },
   {
    title: '员工',
    align:"center",
    dataIndex: 'userId_dictText'
   },
   {
    title: '银行名称',
    align:"center",
    dataIndex: 'bankName'
   },
   {
    title: '银行账号',
    align:"center",
    dataIndex: 'bankNo'
   },
   {
    title: '登记时间',
    align:"center",
    dataIndex: 'regTime'
   },
   {
    title: '下拉多选职务',
    align:"center",
    dataIndex: 'positionIds_dictText'
   },
   {
    title: '文件上传',
    align:"center",
    dataIndex: 'file',
    slots: { customRender: 'fileSlot' },
   },
   {
    title: '头像',
    align:"center",
    dataIndex: 'pic',
    customRender:render.renderImage,
   },
   {
    title: '开关',
    align:"center",
    dataIndex: 'switchId',
    customRender:({text}) => {
       return  render.renderSwitch(text, [{text:'是',value:'Y'},{text:'否',value:'N'}])
     },
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "客户名称",
      field: 'name',
      component: 'Input',
      colProps: {span: 6},
 	},
	{
      label: "下拉状态",
      field: 'status',
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"status"
      },
      colProps: {span: 6},
 	},
	{
      label: "下拉单选职务",
      field: 'positionId',
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"sys_position,name,id"
      },
      colProps: {span: 6},
 	},
	{
      label: "年龄",
      field: 'yearsOld',
      component: 'Input',
      colProps: {span: 6},
 	},
	{
      label: "生日",
      field: 'birtd',
      component: 'DatePicker',
      colProps: {span: 6},
 	},
	{
      label: "单选状态",
      field: 'otherStatus',
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"status"
      },
      colProps: {span: 6},
 	},
	{
      label: "部门",
      field: 'depart',
      component: 'JSelectDept',
      colProps: {span: 6},
 	},
	{
      label: "员工",
      field: 'userId',
      component: 'JSelectUserByDept',
      colProps: {span: 6},
 	},
	{
      label: "银行名称",
      field: 'bankName',
    component: 'JPopup',
    componentProps: ({ formActionType }) => {
        const {setFieldsValue} = formActionType;
        return{
            setFieldsValue:setFieldsValue,
            code:"bank",
            fieldConfig: [
                { source: 'bank_name', target: 'bank_name' },
                { source: 'bank_no', target: 'bank_no' },
            ],
            multi:true
        }
    },

      colProps: {span: 6},
 	},
	{
      label: "银行账号",
      field: 'bankNo',
      component: 'Input',
      colProps: {span: 6},
 	},
	{
      label: "登记时间",
      field: 'regTime',
      component: 'DatePicker',
      componentProps: {
         showTime:true,
         valueFormat: 'YYYY-MM-DD HH:mm:ss'
       },
      colProps: {span: 6},
 	},
	{
      label: "下拉多选职务",
      field: 'positionIds',
      component: 'JSelectMultiple',
      componentProps:{
        dictCode:" sys_position,name,id",
        triggerChange: true
     },
      colProps: {span: 6},
 	},
	{
      label: "文件上传",
      field: 'file',
      component: 'Input',
      colProps: {span: 6},
 	},
	{
      label: "头像",
      field: 'pic',
      component: 'Input',
      colProps: {span: 6},
 	},
	{
      label: "开关",
      field: 'switchId',
      component: 'JSwitch',
      componentProps:{
           query:true,
       },
      colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '客户名称',
    field: 'name',
    component: 'Input',
  },
  {
    label: '下拉状态',
    field: 'status',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"status"
     },
  },
  {
    label: '下拉单选职务',
    field: 'positionId',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"sys_position,name,id"
     },
  },
  {
    label: '年龄',
    field: 'yearsOld',
    component: 'InputNumber',
  },
  {
    label: '生日',
    field: 'birtd',
    component: 'DatePicker',
  },
  {
    label: '单选状态',
    field: 'otherStatus',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"status"
     },
  },
  {
    label: '部门',
    field: 'depart',
     component: 'JSelectDept',
  },
  {
    label: '员工',
    field: 'userId',
    component: 'JSelectUserByDept',
    componentProps:{
        labelKey:'realname',
     },
  },
  {
    label: '银行名称',
    field: 'bankName',
    component: 'JPopup',
    componentProps: ({ formActionType }) => {
        const {setFieldsValue} = formActionType;
        return{
            setFieldsValue:setFieldsValue,
            code:"bank",
            fieldConfig: [
                { source: 'bank_name', target: 'bank_name' },
                { source: 'bank_no', target: 'bank_no' },
            ],
            multi:true
        }
    },

  },
  {
    label: '银行账号',
    field: 'bankNo',
    component: 'Input',
  },
  {
    label: '登记时间',
    field: 'regTime',
    component: 'DatePicker',
    componentProps: {
       showTime: true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
  },
  {
    label: '下拉多选职务',
    field: 'positionIds',
    component: 'JSelectMultiple',
    componentProps:{
        dictCode:" sys_position,name,id"
     },
  },
  {
    label: '文件上传',
    field: 'file',
    component: 'JUpload',
    componentProps:{
     },
  },
  {
    label: '头像',
    field: 'pic',
     component: 'JImageUpload',
     componentProps:{
      },
  },
  {
    label: '开关',
    field: 'switchId',
     component: 'JSwitch',
     componentProps:{
     },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];



/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}